﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MessageServer.utilities;
using MessageServer.serialize;

namespace MessageServer.config
{
    //has all configuration for the message server
    public class MessageServerConfig
    {
        static MessageServerConfig CONFIG = new MessageServerConfig();

        public static MessageServerConfig getInstance()
        {
            return CONFIG;
        }

        const String DB_CONN_STRING = "DB Connection String";
        const String PERSISTENCE_FORMAT = "DB Persistence Format";
        const String PERSISTENT_MESSAGES = "Persistent Message";

        Properties _config = new Properties();

        public MessageServerConfig()
        {
            //TODO: change this
            _config.setProperty(DB_CONN_STRING, "Data Source=10.2.221.73;Initial Catalog=gamblerbonus;User ID=gb;Password=passw0rd;");
            _config.setProperty(PERSISTENCE_FORMAT, typeof(BinarySerializer).FullName);
            _config.setProperty(PERSISTENT_MESSAGES, "false"); //TODO: look at performance when saving to db
        }

        public String connectionString { get { return (String)_config.getProperty(DB_CONN_STRING); } }
        public String persistenceFormat { get { return (String)_config.getProperty(PERSISTENCE_FORMAT); } }
        public bool persistentMessages { get { return _config.getProperty(PERSISTENT_MESSAGES).Equals("true"); } }
    }
}
